(function() {

    "use strict";

    describe("SandboxDomPluginTestCase", function() {

        beforeEach(function() {
            this.plugin = {_findBySelector: window.stubFn(),
                getValue:window.stubFn(),
                setValue:window.stubFn(),
                show:window.stubFn(),
                hide:window.stubFn()};
            var core = {
                getPlugin:window.stubFn(this.plugin)
            };

            this.sandbox = new nw.Sandbox(core);
        });

        afterEach(function() {
        });

        it("should find element", function() {
            this.sandbox.find(".class");
            expect(this.plugin._findBySelector.called).to.be.ok();
            expect(this.plugin._findBySelector.args[0]).to.eql(".class");
        });

        it("should get value", function() {
            this.sandbox.getValue(".class");
            expect(this.plugin.getValue.called).to.be.ok();
            expect(this.plugin.getValue.args[0]).to.eql(".class");
        });

        it("should set value", function() {
            this.sandbox.setValue(".class", 1);
            expect(this.plugin.setValue.called).to.be.ok();
            expect(this.plugin.setValue.args[0]).to.eql(".class");
            expect(this.plugin.setValue.args[1]).to.eql(1);
        });

        it("should show element", function() {
            var element = {};
            this.sandbox.show(element);
            expect(this.plugin.show.called).to.be.ok();
            expect(this.plugin.show.args[0]).to.eql(element);
        });

        it("should hide element", function() {
            var element = {};
            this.sandbox.hide(element);
            expect(this.plugin.hide.called).to.be.ok();
            expect(this.plugin.hide.args[0]).to.eql(element);
        });
    });

    describe("SandboxTemplatePluginTestCase", function() {

        beforeEach(function() {
            this.plugin = {render: window.stubFn()};
            var core = {
                getPlugin:window.stubFn(this.plugin)
            };

            this.sandbox = new nw.Sandbox(core);
        });

        it("should render template", function() {
            var view = {};
            var model = {};
            this.sandbox.render("view-template", view, model);

            expect(this.plugin.render.called).to.be.ok();
            expect(this.plugin.render.args[0]).to.eql("view-template");

            expect(this.plugin.render.args[1]).to.eql(view);
            expect(this.plugin.render.args[2]).to.eql(model);
        });
    });

	describe("SandboxViewsTestCase", function() {

		beforeEach(function() {
			this.core = {
				getPlugin:window.stubFn()
			};
		});

		it("should get the current view name", function() {
			var viewName = "test view";
			this.core.currentViewName = viewName;
			var sandbox = new nw.Sandbox(this.core);
			var currentViewName = sandbox.getCurrentViewName();

			expect(currentViewName).to.eql(viewName);
		});
	});

    describe("SandboxEventsTestCase", function() {

        beforeEach(function() {
            this.plugin = {
                bind: window.stubFn()
            };
            var core = {
                getPlugin:window.stubFn(this.plugin)
            };

            this.sandbox = new nw.Sandbox(core);
        });

        it("should bind onClick event", function() {
            var handler = function(){};
            this.sandbox.onClick(".test", handler);

            expect(this.plugin.bind.called).to.be.ok();
            expect(this.plugin.bind.args[0]).to.eql(".test");
            expect(this.plugin.bind.args[1]).to.eql("click");
            expect(this.plugin.bind.args[2]).to.eql(handler);
        });
    });
}());